package com.tensquare.chat.dao;
/*
 *ClassName:MesageDao
 *Description:
 *@author:可爱的大鸭子
 */

import com.tensquare.chat.pojo.SocketMessage;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.List;

public interface MessageDao extends MongoRepository<SocketMessage,String>{
    //查询聊天记录按时间排序
    List<SocketMessage> findAllByFromAndToOrderByPublishtimeDesc(String from,String to);
    //查询我的未读消息总数
    Integer countAllByToAndReaded(String to,String readed);
    //查询某个人给我发的未读消息总数
    Integer countAllByFromAndToAndReaded(String from,String to,String readed);
    //查询某个人给我发的最新的未读消息
    SocketMessage findTopByFromAndToAndReadedOrderByPublishtimeDesc(String from,String to,String readed);

}
